package cn.jinjimi.app.main.dialog;

import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.view.View;

import cn.jinjimi.app.R;
import cn.jinjimi.app.bean.QuesCode;
import cn.jinjimi.app.controller.event.CallShareDialogEvent;
import cn.jinjimi.app.main.activity.LoginActivity;
import cn.jinjimi.app.main.activity.ReaderDetailActivity;

import org.greenrobot.eventbus.EventBus;

/**
 * Created by HANER on 15/3/30.
 */
public class ShareWithoutLoginDialog extends Dialog implements View.OnClickListener {

    private View nextTime;
    private View getCard;
    private Context context;

    public ShareWithoutLoginDialog(Context context) {
        super(context, R.style.TransparentDialog);
        this.context = context;
        initView();
        initListener();
    }

    private void initListener() {
        nextTime.setOnClickListener(this);
        getCard.setOnClickListener(this);
    }

    private void initView() {
        setContentView(R.layout.dialog_share_withoutlogin);
        nextTime = findViewById(R.id.button_next_time);
        getCard = findViewById(R.id.button_get_weimingpian);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.button_next_time:
                EventBus.getDefault().post(new CallShareDialogEvent());
                break;
            case R.id.button_get_weimingpian:
                Intent intent = new Intent(context, LoginActivity.class);
                ((ReaderDetailActivity) context).startActivityForResult(intent, QuesCode.QuestShareArticle);
                break;
        }
        dismiss();
    }
}
